﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Talento21.Modelo;

namespace Talento21.Negocio.Servicio
{
    public class SrvCargosEmp
    {
        SysGestion21Entities db;

        public SrvCargosEmp()
            : this(new SysGestion21Entities())
        {

        }

        public SrvCargosEmp(SysGestion21Entities context)
        {
            db = context;
        }

        public List<InfCargosEmp> ObtenerCargosPorRutEmpresa(int emp_rut)
        {
            return (from cargosEmpresa in db.InfCargosEmp where cargosEmpresa.Emp_Rut == emp_rut select cargosEmpresa).ToList();
        }

        public List<InfCargosEmp> ObtenerCargoPorId(int id)
        {
            return (from cargosEmpresa in db.InfCargosEmp where cargosEmpresa.Id_Cargo == id select cargosEmpresa).ToList();
        }

        public void Crear(InfCargosEmp cargo)
        {
            
            db.AddToInfCargosEmp(cargo);
            db.SaveChanges();
        }

        public void Modificar(InfCargosEmp cargo)
        {

            db.InfCargosEmp.AddObject(cargo);
            db.ObjectStateManager.ChangeObjectState(cargo, System.Data.EntityState.Modified);
            db.SaveChanges();
        }


    }
}